package bit_operation;

import java.util.HashMap;
import java.util.Map;

public class singleNumber3 {
    //Hash
    public int[] singleNumber(int[] nums) {
        Map<Integer,Integer> freq = new HashMap<>();
        for(int num:nums) {
            freq.put(num,freq.getOrDefault(num,0)+1);
        }
        int[] ret = new int[2];
        int index = 0;
        for(Map.Entry<Integer,Integer> entry : freq.entrySet()) {
            if(entry.getValue() == 1) {
                ret[index++] = entry.getKey();
            }
        }
        return ret;
    }
}
